/*
 *@本js功能：首页
 *@本js作者：杨锡君
 *@编写时间：2017年10月25日
 */
$(function(){
    var Alert1 = new Alert();
    var confirm1 = new Confirm();
    var $wrapIndex = $(".wrapIndex");
    var $left = $(".main>.left");
    var $iframeBox = $(".iframeBox");
    var $box_1 = $(".box_1");
    var $ifMain = $("#ifMain");
    var $adminNav = $(".adminNav");
    var $teaNav = $(".teaNav");
    var $stuNav = $(".stuNav");
    var $mainNav = $(".mainNav");
    var $exit = $(".exit");
    var $mb = $(".mb");
    var filename= "";
    var $userHead = $(".userHead");
    var passwordModel = "<div class=\"popup\">"
        +"<div class=\"popup_box\">"
        +"<div class=\"popup_contenthead\">修改密码<img class=\"popup_img\" src=\"pc/images/ico_alertDel.png\"></div>"
        +"<div class=\"popup_content\">"
        +"<div><label>&emsp;原密码&ensp;:&ensp;</label>"
        +"<input type=\"password\" name=\"password1\"  style=\"display:none\"/>"
        +"<input autocomplete=\"off\" maxlength=\"20\" type=\"text\"  onfocus='this.type=\"password\"'  class=\"publicText oldPass\"/></div>"
        +"<div><labeb>&emsp;新密码&ensp;:&ensp;</label>"
        +"<input autocomplete=\"off\" maxlength=\"20\" onfocus='this.type=\"password\"' type=\"text\" class=\"publicText newPass\" /></div>"
        +"<div><label>确认密码&ensp;:&ensp;</label>"
        +"<input maxlength=\"20\" type=\"text\"  onfocus='this.type=\"password\"'  class=\"publicText rePass\" /></div>"
        +"</div>"
        +"<div class=\"popup_btn\">"
        +"<a class=\"popup_confirm exportBtn hover-btn\">确定</a>"
        +"<a class=\"popup_close exportCancle hover-btn\">取消</a>"
        +"</div>"
        +"<div class=\"clear\"></div>"
        +"</div>"
        +"</div>";
    var headerChangeModel = "<div class=\"popup headerPopup\" >"
        +"<form id=\"uploadForm\" method=\"post\"  enctype=\"multipart/form-data\">"
        +"<div class=\"popup_box\">"
        +"<div class=\"popup_contenthead\">修改头像<img class=\"popup_img\" src=\"pc/images/ico_alertDel.png\"></div>"
        +"<div class=\"popup_content popup_contents\" >"
        +"<div class=\"headerAll\">"
        +"<div title=\"ico_testHeader1.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader1.jpg\"/></div>"
        +"<div title=\"ico_testHeader2.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader2.jpg\"/></div>"
        +"<div title=\"ico_testHeader3.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader3.jpg\"/></div>"
        +"<div style=\"margin-right: 0\" title=\"ico_testHeader4.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader4.jpg\"/></div>"
        +"<div title=\"ico_testHeader5.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader5.jpg\"/></div>"
        +"<div title=\"ico_testHeader6.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader6.jpg\"/></div>"
        +"<div title=\"ico_testHeader7.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader7.jpg\"/></div>"
        +"<div style=\"margin-right: 0\"  title=\"ico_testHeader8.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader8.jpg\"/></div>"
        +"<div title=\"ico_testHeader9.jpg\" class=\"fl oneHead\"><img src=\"pc/images/ico_testHeader9.jpg\"/></div>"
        +"</div>"
        +"<label class=\"headFileBtn\" for=\"apkFile\">选择本地文件...</label>"
        +"<div class=\"localPhotoBox\">"
        +"</div>"
        +"<input type=\"file\" name=\"apkFile\" id=\"apkFile\"  style=\"display: none;\" />"
        +"<input type=\"text\" name=\"bdImage\" id=\"bdImage\"  style=\"display: none;\" />"
        +"</div>"
        +"<div class=\"popup_btn\">"
        +"<button type=\"submit\" class=\"popup_confirm exportBtn hover-btn publicBtn\">确定</button>"
        +"<a class=\"popup_close exportCancle hover-btn\">取消</a>"
        +"</div>"
        +"<div class=\"clear\"></div>"
        +"</div>"
        +"</form>"
        +"</div>";
    var index = {
        init:function(){
            this.layout();
            this.bindEvent();
        },
        bindEvent:function(){
            var self = this;
            self.navEvent();
            self.selectEvent();
            self.exitEvent();
            $(".moveArrow").off("click").click(function(){
                self.leftNone();
            });
            //			修改密码
            $(".passFun").off("click").click(function(){
                self.passFun();
                maxLengthLimit.init("publicText");
            });
            // 获取头像
            self.getHead();
            $userHead.off("click").click(function(){
                self.headerChange();
            });
            //			我的信息
            var roleId = result.roleId;
            $(".inforFun").off("click").click(function(){
                $(".mainNav").empty();
                $(".box_1").removeClass("navBg");
                $(".box_1").attr("data-no",0);
                self.inforFun(roleId);
            });
            //			消息通知
            $(".noticeFun").off("click").click(function(){
                $(".mainNav").empty();
                $(".box_1").removeClass("navBg");
                $(".box_1").attr("data-no",0);
                if(roleId == 1){
                    var json = JSON.stringify({
                        "pageName":"studentMessageNotification",
                        "paramData":{
                            "roleId":roleId
                        }
                    });
                    $ifMain.attr("src","skipPage?jsonStr=" + json);
                }else if(roleId == 2){
                    var json = JSON.stringify({
                        "pageName":"teacherMessageNotification",
                        "paramData":{
                            "roleId":roleId
                        }
                    });
                    $ifMain.attr("src","skipPage?jsonStr=" + json);
                }else{
                    var json = JSON.stringify({
                        "pageName":"adminMessageNotification",
                        "paramData":{
                            "roleId":roleId
                        }
                    });
                    $ifMain.attr("src","skipPage?jsonStr=" + json);
                }
            });
            // 回首页
            $(".box_4").off("click").click(function () {
                // if(result.roleId == 1){
                //     var json = JSON.stringify({
                //         "pageName":"stuIndex"
                //     });
                //     $ifMain.attr("src","skipPage?jsonStr=" + json);
                // }
                // if(result.roleId == 2){
                //     var json = JSON.stringify({
                //         "pageName":"teaIndex"
                //     });
                //     $ifMain.attr("src","skipPage?jsonStr=" + json);
                // }
                window.location.reload(true);
            });
        },
        inforFun:function (roleId) {
            if(roleId == 1){
                var json = JSON.stringify({
                    "pageName":"studentMyInformation"
                });
                $ifMain.attr("src","skipPage?jsonStr=" + json);
            }else if(roleId == 2){
                var json = JSON.stringify({
                    "pageName":"teacherMyInformation"
                });
                $ifMain.attr("src","skipPage?jsonStr=" + json);
            }else{
                var json = JSON.stringify({
                    "pageName":"adminrMyInformation"
                });
                $ifMain.attr("src","skipPage?jsonStr=" +json);
            }
        },
        getHead:function () {
            var role = result.roleId;
            var param = 0;
            if(role == 1){
                param =3;
            }
            if(role == 2){
                param =2;
            }
            if(role == 3 || role == 4){
                param =1;
            }
            var json = JSON.stringify({
                "pageNow":0,
                "pageSize":10,
                "param":param,
                "roleId":role,
                "selecetRoleId":role,
                "stuorteaId":result.stuorteaId
            });
            $.ajax({
                url: 'getMemberDetailById',
                type: 'post',
                data: {
                    "jsonStr":json
                },
                async: false,
                success:function (msg) {
                    msg = JSON.parse(msg);
                    // if(msg.result == "success"){
                    var str = "";
                    $(".userName").html("你好!&ensp;"+msg.memberList[0].userName);
                    $(".userName").attr("title",msg.memberList[0].userName);
                    if(msg.memberList[0].headIcon == ""){
                        str = "url(../../images/ico_testHead.jpg) no-repeat center";
                    }else{
                        $userHead.css({"background":"url("+msg.imageUrl +"/"+ msg.memberList[0].headIcon +") no-repeat center","background-size": "contain"});
                    }

                    // }
                }
            })
        },
        headerChange:function(){
            var self = this;
//			修改头像
            if($(".headerPopup").length == 0){
                $mb.show();
                $("body").append(headerChangeModel);
            }
            //取消和X事件
            $(".popup_img").off("click").on("click", function() {
                $(".headerPopup").remove();
                $mb.hide();
            });
            $(".exportCancle").off("click").on("click", function() {
                $(".headerPopup").remove();
                $mb.hide();
            });
            $(".oneHead").off("click").on("click", function() {
                $(".oneHead").removeClass("headerChose");
                $(this).addClass("headerChose");
            });
            var flag = self.fileEvent();
            $("#uploadForm").submit(function(){
                if($(".headerChose").length == 0){
                    Alert1.content = "请选择头像";
                    Alert1.success = function () {
                        if($(".headerPopup").length == 0){
                            $mb.show();
                            $("body").append(headerChangeModel);
                        }
                    };
                    Alert1.init();
                    Alert1.show();

                    return false;
                }else{
                    if($(".headerChose").attr("title") == undefined){
                        // $("#bdImage").val("");
                    }else{
                        $("#bdImage").val($(".headerChose").attr("title"));
                    }
                    var formData = new FormData(this);
                    $.ajax({
                        url: 'updateHeadIcon',
                        type: 'post',
                        data: formData,
                        async: false,
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (msg) {
                            msg = JSON.parse(msg);
                            if(msg.resultFlag == true){
                                Alert1.content = "上传头像成功";
                                Alert1.success = function () {
                                    $(".headerPopup").remove();
                                    $mb.hide();
                                    $userHead.css({"background":"url("+ msg.headUrl +") no-repeat center","background-size":"contain"});
                                };
                                Alert1.init();
                                Alert1.show();
                            }else{
                                Alert1.content = msg.msg;
                                Alert1.init();
                                Alert1.show();
                                if($(".headerPopup").length == 0){
                                    $mb.show();
                                    $("body").append(headerChangeModel);
                                }
                            }
                            return false;
                        }
                    });
                    return false;
                }

            });

        },
        fileEvent: function() {
            $("#apkFile").off("change").change(function() {
                var type = $(this).val().substring($(this).val().lastIndexOf(".")).toLowerCase(); // 取文件格式后缀名
                if(type != ".jpg" && type != ".jpeg"&& type != ".gif"&& type != ".png") {
                    $("#apkFile").val("");
                    Alert1.content = "请上传图片文件，谢谢合作！";
                    Alert1.success = function () {
                        if($(".headerPopup").length == 0){
                            $mb.show();
                            $("body").append(headerChangeModel);
                        }
                    };
                    Alert1.init();
                    Alert1.show();
                    return false;
                } else {
                    var imgUrl = getImgURL(document.getElementById("apkFile"));
                    $(".oneHead").removeClass("headerChose");
                    filename = $(this).val().substring($(this).val().lastIndexOf("\\")+1);
                    $(".localPhotoBox").html("<div class=\"oneHead headerChose\"><img src="+ imgUrl +"></div>")
                    $(".oneHead").off("click").on("click", function() {
                        $(".oneHead").removeClass("headerChose");
                        $(this).addClass("headerChose");
                    });
                    return true;
                }
            });
        },
        passFun:function(){
//			修改密码
            if($(".popup").length == 0){
                $("body").append(passwordModel);
            }else{
                $(".popup").show();
            }

            $mb.show();
            //				X
            $(".popup_img").off("click").click(function() {
                $(".popup").hide();
                $(".mb").hide();
                $(".publicText").val("");
            });
            //取消
            $(".exportCancle").off("click").click(function() {
                $(".popup").hide();
                $(".mb").hide();
                $(".publicText").val("");
            });
            $(".exportBtn").off("click").click(function() {
                var isOk = true;
                var oldPass = $(".oldPass").val();
                if(oldPass == ""){
                    Alert1.content = "请输入原密码";
                    Alert1.init();
                    Alert1.show();
                    isOk = false;
                    return false;
                }
                var flages = verification.spaceCode(oldPass);
                var flagses = verification.specialCode(oldPass);
                if(flages != true) {
                    Alert1.content = "原密码"+flages;
                    $(".oldPass").val("");
                    Alert1.init();
                    Alert1.show();
                    isOk = false;
                    return false;
                }
                if(flagses != true) {
                    Alert1.content = "原密码"+flagses;
                    $(".oldPass").val("");
                    Alert1.init();
                    Alert1.show();
                    isOk = false;
                    return false;
                }
                var newPass = $(".newPass").val();
                if(newPass == ""){
                    Alert1.content = "请输入新密码";
                    Alert1.init();
                    Alert1.show();
                    isOk = false;
                    return false;
                }
                var flag = verification.spaceCode(newPass);
                var flags = verification.specialCode(newPass);
                if(flag != true) {
                    Alert1.content = "新密码"+flag;
                    $(".newPass").val("");
                    Alert1.init();
                    Alert1.show();
                    isOk = false;
                    return false;
                }
                if(flags != true) {
                    Alert1.content = "新密码"+flags;
                    $(".newPass").val("");
                    Alert1.init();
                    Alert1.show();
                    return false;
                }
                var rePass = $(".rePass").val();
                if(rePass == ""){
                    Alert1.content = "请输入确认密码";
                    Alert1.init();
                    Alert1.show();
                    isOk = false;
                    return false;
                }
                if(newPass != rePass){
                    Alert1.content = "两次密码输入不一致请重新输入";
                    Alert1.init();
                    Alert1.show();
                    isOk = false;
                    return false;
                }
                var jsonStr = JSON.stringify({
                    "befPassword":oldPass,
                    "password":newPass
                });
                if(isOk){
                    $.ajax({
                        type:"post",
                        url:"forgetPasswordSubmit",
                        async:true,
                        data:{
                            "jsonStr":jsonStr
                        },
                        success:function(msg){
                            msg = JSON.parse(msg);
                            if(msg.result == "success"){
                                Alert1.content = "密码修改成功";
                                Alert1.success = function(){
                                    $mb.hide();
                                    $(".popup").remove();
                                    window.location.href = "logOut";
                                };
                                Alert1.init();
                                Alert1.show();
                            }else{
                                Alert1.content = msg.msg;
                                Alert1.init();
                                Alert1.show();
                                if($(".popup").length == 0){
                                    $("body").append(passwordModel);
                                }else{
                                    $(".popup").show();
                                }
                                $mb.show();
                            }
                        }
                    });
                }

            });
        },
        leftNone:function(){
//			左侧导航
            var self = this;
            $left.animate({"width":"0"},300);
            $(".moveArrow").animate({"left":"0"},300);
            $(".moveArrow").addClass("moveBack");
            $(".moveArrow").removeClass("moveArrow");
            $iframeBox.animate({"width":$(window).width()+"px"},300);
            $(".userInforBox,.mainNav").hide();
            $(".moveBack").off("click").click(function(){
                self.leftBlock();
            });
        },
        leftBlock:function(){
            //			左侧导航
            var self = this;
            $iframeBox.animate({"width":$(window).width()-240+"px"},300);
            $left.animate({"width":"240px"},300);
            $(".moveBack").addClass("moveArrow");
            $(".moveBack").animate({"left":"212px"},300);
            $(".moveBack").removeClass("moveBack");
            $(".userInforBox,.mainNav").show();
            $(".moveArrow").off("click").click(function(){
                self.leftNone();
            });
        },
        exitEvent:function(){
            //退出系统
            $exit.off("click").click(function(){
                confirm1.content = "确认退出系统吗？";
                confirm1.success = function(){
                    window.location.href = "logOut";
                };
                confirm1.init();
                confirm1.show();
            });
        },
        navEvent:function(){
            //上方导航事件
            $(".box_1").click(function(){
                $box_1.removeClass("navBg");
                $box_1.attr("data-no","0");
                $(this).addClass("navBg");
                $(this).attr("data-no","1");

            });

        },
        selectEvent:function(){
            /*导航下拉展开事件*/
            $(".navFirst[data-num='0']").off("click").click(function(){
                $(".navFirst").children("a").removeClass("leftClick");
                $(".navFirst").attr("data-num","0");
                $(".navSecond").children("a").removeClass("leftClick");
                $(".navSecond").attr("data-no","0");
                $(this).children("a").addClass("leftClick");
                $(this).attr("data-num","1");
                //点击跳转

                if($(this).attr("data-url") != undefined){
                    var json = {
                        "pageName": $(this).attr("data-url")
                    };
                    if($(this).attr("data-courseid") != undefined){
                        json = {
                            "pageName": $(this).attr("data-url"),
                            "paramData":{
                                "courseId":Number($(this).attr("data-courseid"))
                            }
                        };
                    }
                    $ifMain.attr("src","skipPage?jsonStr=" + JSON.stringify(json));
                }
            });
            $(".navFirst[data-num='0']").off("hover").hover(function(){
                $(this).children("a").addClass("leftClick");

            },function(){
                $(".navFirst[data-num='0']").children("a").removeClass("leftClick");
            });
            $(".navSecond[data-no='0']").off("click").click(function(e){
                $(".navSecond").children("a").removeClass("leftClick");
                $(".navSecond").attr("data-no","0");
                $(this).parent().parent().siblings("li").children("a").removeClass("leftClick");
                $(this).parent().parent().siblings("li").attr("data-num","0");
                $(this).parent().parent().children("a").addClass("leftClick");
                $(this).parent().parent().attr("data-num","1");
                $(this).children("a").addClass("leftClick");
                $(this).attr("data-no","1");
                if($(this).attr("data-url") != undefined){
                    var json = {
                        "pageName": $(this).attr("data-url")
                    };
                    if($(this).attr("data-courseid") != undefined){
                        json = {
                            "pageName": $(this).attr("data-url"),
                            "paramData":{
                                "courseId":Number($(this).attr("data-courseid"))
                            }
                        };
                    }

                    $ifMain.attr("src","skipPage?jsonStr=" + JSON.stringify(json));
                }
                var e = e || event;
                e.stopPropagation();
            });
            $(".navSecond[data-no='0']").off("hover").hover(function(){
                $(this).children("a").addClass("leftClick");
            },function(){
                $(".navSecond[data-no='0']").children("a").removeClass("leftClick");
            });
            $(".left span").off("click").off("click").click(function(e) {
                if($(this).hasClass("up")) {
                    $(this).removeClass("up");
                    $(this).addClass("down");
                    $(this).parent().parent().parent().find("ul").slideToggle(300);
                } else {
                    $(".subNav").slideUp(300);
                    $(".left .mainNav .navFirst span").removeClass("up");
                    $(".left .mainNav .navFirst  span").addClass("down");
                    $(this).removeClass("down");
                    $(this).addClass("up");
                    $(this).parent().parent().parent().find("ul").slideToggle(300);
                }

            });
        },
        adminClickEvent:function(){
//			管理员导航点击事件
            var self = this;
            $(".intitutionMana").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="adminOrganizational" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;院系管理</a></div><div data-num="0" data-url="adminDepartmentManagement"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;部门管理</a></div><div data-num="0" data-url="adminLocationManagement" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;教学地点管理</a></div><div data-num="0" data-url="adminIconMana" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;图标管理</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "adminOrganizational"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".teachMana").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="adminTeacherManagement" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;教师管理</a></div><div data-num="0" data-url="adminClassMana" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;班级管理</a></div><div data-num="0" class="navFirst"><a href="javascript:;" class="nav_0"><div><span class="down">&emsp;&emsp;&emsp;&ensp;排课管理</span></div></a><ul class="subNav"><li data-no="0" data-url="courseArrangeMana"  class="navSecond"><a href="javascript:;" class="nav_00_1" target="mainframe">手动排课</a></li><li data-no="0" data-url="autoCourseArrangeMana"  class="navSecond"><a href="javascript:;" class="nav_00_1" target="mainframe">自动排课</a></li></div><div data-num="0" data-url="adminCourseManagement" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;排课详情</a></div><div data-num="0" data-url="adminLessonSummary" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;任课概要</a></div><div data-num="0" class="navFirst"><a href="javascript:;" class="nav_0"><div><span class="down">&emsp;&emsp;&emsp;&ensp;课程库</span></div></a><ul class="subNav"><li data-no="0" data-url="adminCourseLibrary" class="navSecond"><a href="javascript:;" class="nav_00_1" target="mainframe">预置课程</a></li><li data-no="0" data-url="adminCourseLibraryCustomization" class="navSecond"><a href="javascript:;" class="nav_00_1" target="mainframe">自定义课程</a></li></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "adminTeacherManagement"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });

            $(".interflow").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="adminCourseInterflow" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;课程交流管理</a></div><div data-num="0" data-url="adminBlack" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;黑名单管理</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "adminCourseInterflow"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".virtualMana").off("click").click(function(){
                // $mainNav.html('<div data-num="0" data-url="virMachineSch" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;虚机查询</a></div><div data-num="0" data-url="imageConfig" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;镜像配置</a></div><div data-num="0" data-url="teaVirrAllocation" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;教师虚机分配</a></div><div data-num="0" data-url="stuVirrAllocation"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;学生虚机分配</a></div>');
                $mainNav.html('<div data-num="0" data-url="virMachineSch" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;虚机查询</a></div><div data-num="0" data-url="imagesConfig" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;集群配置</a></div><div data-num="0" data-url="imageAllocate" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;模板配置</a></div><div data-num="0" data-url="imageMana"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;镜像管理</a></div><div data-num="0" data-url="virDestroy"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;虚机销毁</a></div><div data-num="0" data-url="virSaveCount"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;教师镜像保存数量</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "virMachineSch"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".userMana").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="adminUserManagement"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;用户管理</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "adminUserManagement"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".paraMana").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="adminParameterManagement"   class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;功能开关设置</a></div><div  data-url="adminCourseSchedulingTime" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;排课时间设置</a></div><div  data-url="adminWeightSet" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;学生能力权重配置</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "adminParameterManagement"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".helpAdminText").off("click").click(function(){
//				帮助文档
                $mainNav.html('<div data-num="0" data-url="adminParameterManagement"   class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;帮助文档</a></div>');
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                $ifMain.attr("src","pc/page/adminHelpText.html");
            });
        },
       teaClickEvent:function(){
            var self = this;
            $(".teaMyCourse").off("click").click(function(){
//				获取课程
                $.ajax({
                    type:"post",
                    url:"skipMyCourse",
                    async:true,
                    success:function(msg){
                        msg = JSON.parse(msg);
                        var str ="";
                        var n = 0;
                        if(msg.courseList.length!=0){
                            $.map(msg.courseList, function(opt) {
                                str += '<div data-num="0"  data-url="myCourse"  data-courseid='+ opt.courseId +'  class="navFirst"><a href="javascript:;" title='+ opt.courseName +' class="nav_0">&emsp;&emsp;&emsp;&emsp;'+ opt.courseName +'</a></div>';
                            });
                            $mainNav.html(str);
                            self.selectEvent();
                            $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                            var json = JSON.stringify({
                                "pageName": "myCourse",
                                "paramData":{
                                    "courseId":Number($(".navFirst").eq(0).attr("data-courseid"))
                                }
                            });

                            $ifMain.attr("src","skipPage?jsonStr=" + json);
                        }else{
                            Alert1.content = "当前没有课程，请联系管理员分配课程";
                            Alert1.init();
                            Alert1.show();
                        }

                    }
                });

            });
            // $(".makeCourse").off("click").click(function(){
            //     $mainNav.html('<div data-num="0"  data-url="preserveCourse" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;制作课程</a></div><div data-num="0"  data-url="chapterMake" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;制作章节</a></div>');
            //     self.selectEvent();
            //     $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
            //     $(".navFirst").eq(0).find(".down").addClass("up").removeClass("down");
            //     $(".navSecond").eq(0).attr("data-no","1").find(".nav_00_1").eq(0).addClass("leftClick");
            //     //默认跳转
            //     var json = JSON.stringify({
            //         "pageName": "preserveCourse"
            //     });
            //
            //     $ifMain.attr("src","skipPage?jsonStr=" + json);
            // });

           $(".makeCourse").off("click").click(function(){
               $mainNav.html('<div data-num="0"  data-url="preserveCourse" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;制作课程</a></div><div data-num="0"  data-url="chapterMake" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;制作章节</a></div><div data-num="0"  data-url="fishHead" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;制作大纲</a></div>');
               self.selectEvent();
               $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
               $(".navFirst").eq(0).find(".down").addClass("up").removeClass("down");
               $(".navSecond").eq(0).attr("data-no","1").find(".nav_00_1").eq(0).addClass("leftClick");
               //默认跳转
               var json = JSON.stringify({
                   "pageName": "preserveCourse"
               });

               $ifMain.attr("src","skipPage?jsonStr=" + json);
           });




            $(".teaMana").off("click").click(function(){
                $mainNav.html('<div data-num="0"  data-url="teacherClassManagement" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;班级管理</a></div><div  data-url="teacherExperimentalManagement" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;实验管理</a></div><div data-url="teacherJobManagement" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;作业管理</a></div><div data-num="0" data-url="teacherGradeManagement" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;成绩管理</a></div><div data-url="teacherAchievementWeight" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;成绩设置</a></div><div data-url="teacherFileChecking" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;文件查重</a></div><div data-url="teacherPostSkills" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;岗位技能</a></div><div data-url="phone" data-num="0" class="navFirst"></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "teacherClassManagement"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
           $(".virtualMana").off("click").click(function(){
               $mainNav.html('<div data-num="0" data-url="teaVirMachineSch" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;虚机查询</a></div><div data-num="0" data-url="teaImagesConfig"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;集群配置</a></div><div data-num="0" data-url="teaImageAllocate" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;模板配置</a></div><div data-num="0" data-url="teaImageMana"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;镜像管理</a></div>');
               self.selectEvent();
               $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
               //默认跳转
               var json = JSON.stringify({
                   "pageName": "teaVirMachineSch"
               });

               $ifMain.attr("src","skipPage?jsonStr=" + json);
           });
            $(".testMana").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="testBaseMana" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;题库管理</a></div><div data-url="testGenerate" data-num="0" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;生成试卷</a></div><div data-num="0"  data-url="testReviewMana" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;在线批阅</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "testBaseMana"
                });
                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".teaIssue").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="teacherAnswer"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;课程问答</a></div><div data-num="0"  data-url="teacherMyQuestion" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;我的提问</a></div><div data-num="0"  data-url="teacherMyAnswer" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;我的回答</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "teacherAnswer"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".teaSet").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="courseSt"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;教学统计分析</a></div><div data-num="0"  data-url="stuReportList" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;学生统计分析</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "courseSt"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".helpTeaText").off("click").click(function(){
//				帮助文档
                $mainNav.html('<div data-num="0" data-url="adminParameterManagement"   class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;帮助文档</a></div>');
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                $ifMain.attr("src","pc/page/teaHelpText.html");
            });
        },
        stuClickEvent:function(){
            var self = this;
            $(".stuMyCourse").off("click").click(function(){
//				获取课程
                $.ajax({
                    type:"post",
                    url:"skipMyCourse",
                    async:true,
                    success:function(msg){
                        msg = JSON.parse(msg);
                        var str ="";
                        var n = 0;
                        if(msg.courseList.length!=0){
                            $.map(msg.courseList, function(opt) {
                                str += '<div data-num="0"  data-url="myCourse"  data-courseid='+ opt.courseId +'  class="navFirst"><a href="javascript:;" title='+  opt.courseName +' class="nav_0">&emsp;&emsp;&emsp;&emsp;'+ opt.courseName +'</a></div>';
                            });
                            $mainNav.html(str);
                            self.selectEvent();
                            $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                            //默认跳转
                            var json = JSON.stringify({
                                "pageName": "myCourse",
                                "paramData":{
                                    "courseId":Number($(".navFirst").eq(0).attr("data-courseid"))
                                }
                            });

                            $ifMain.attr("src","skipPage?jsonStr=" + json);
                        }else{
                            Alert1.content = "当前没有课程，请联系管理员分配课程";
                            Alert1.init();
                            Alert1.show();
                        }

                    }
                });
            });
            $(".choseCourse").off("click").click(function(){
                $mainNav.html('<div data-num="0"  data-url="studentCourseSelection" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;选课申请</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "studentCourseSelection"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".courseSearch").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="studentScoreQuery"   class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;成绩查询</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "studentScoreQuery"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".onlineTest").off("click").click(function(){
//				获取课程
                $mainNav.html('<div data-num="0" data-url="stuOnlineExam"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;在线考试</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "stuOnlineExam"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".stuIssue").off("click").click(function(){
                $mainNav.html('<div data-num="0" data-url="studentAnswer"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;课程问答</a></div><div data-num="0" data-url="studentMyQuestion"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;我的提问</a></div><div data-num="0" data-url="studentMyAnswer"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;我的回答</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "studentAnswer"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
            $(".stuReport").off("click").click(function(){
//				获取课程
                $mainNav.html('<div data-num="0" data-url="stuReports"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;我的报告</a></div>');
                self.selectEvent();
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "stuReports"
                });

                $ifMain.attr("src","skipPage?jsonStr=" + json);
            });
        },
        layout:function(){
            //布局
            //权限
            //消息推送
            // setTimeout(function (args) {
            //     var json = JSON.stringify({
            //         "pageName":"stuOnlineExamDetail",
            //         "paramData":{
            //             "courseId":90
            //         }
            //     });
            //     $ifMain.attr("src","skipPage?jsonStr=" + json);
            // },3000)
            var self = this;
            $ifMain.load(function () {
                self.selectEvent();
            });
            var author = result.roleId;
            if(author == 1){
                $stuNav.show();
                $teaNav.remove();
                $adminNav.remove();
                $.ajax({
                    type: "post",
                    url: "skipParamMana",
                    async: true,
                    success: function (msg) {
                        msg = JSON.parse(msg);
                        if(msg.selectCourseMark	== 2){
                            $(".choseCourse").remove();
                        }
                        if(msg.selectAnswerMark == 2){
                            $(".stuIssue").remove();
                        }
                    }
                });
                self.stuClickEvent();
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "stuIndex"
                });
                // $ifMain.attr("src","skipPage?jsonStr=" + json);;
                $ifMain.attr("src","skipPage?jsonStr=" + json);
            }

            if(author == 2){
                $teaNav.show();
                $stuNav.remove();
                $adminNav.remove();
                self.teaClickEvent();
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "teaIndex"
                });
                $.ajax({
                    type: "post",
                    url: "skipParamMana",
                    async: true,
                    success: function (msg) {
                        msg = JSON.parse(msg);
                        if(msg.selectAnswerMark == 2){
                            $(".teaIssue").remove();
                        }
                    }
                });
                // $ifMain.attr("src","skipPage?jsonStr=" + json);;
                $ifMain.attr("src","skipPage?jsonStr=" + json);

            }
            if(author == 3|| author == 4){
                $adminNav.show();
                $teaNav.remove();
                $stuNav.remove();
                self.adminClickEvent();
                $mainNav.html('<div data-num="0" data-url="adminOrganizational" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;院系管理</a></div><div data-num="0" data-url="adminDepartmentManagement"  class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;部门管理</a></div><div data-num="0" data-url="adminLocationManagement" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;教学地点管理</a></div><div data-num="0" data-url="adminIconMana" class="navFirst"><a href="javascript:;" class="nav_0">&emsp;&emsp;&emsp;&ensp;图标管理</a></div>');
                self.selectEvent();
                $(".intitutionMana").addClass("navBg").attr("data-no","1");
                $(".navFirst").eq(0).attr("data-num","1").find(".nav_0").addClass("leftClick");
                self.selectEvent();
                //默认跳转
                var json = JSON.stringify({
                    "pageName": "adminOrganizational"
                });
                $ifMain.attr("src","skipPage?jsonStr=" + json);
                // 超管销户
                if(author == 3){
                    $(".passFun").html("<img src=\"pc/images/ico_myId.png\">我的账户");
                    $(".passFun").addClass("myId");
                    $(".passFun").removeClass("passFun");
                    $(".myId").off("click").click(function () {
                        var json = JSON.stringify({
                            "pageName": "adminMyId"
                            // "paramData":{
                            //     "stuorteaId":result.stuorteaId
                            // }
                        });

                        $ifMain.attr("src","skipPage?jsonStr=" + json);
                    });
                }

            }
            if(author == 4){
                $(".userMana").remove();
            }

            $wrapIndex.height($(window).height());
            $left.height($(window).height()-80);
            $iframeBox.width($(window).width()-$left.width());
            $iframeBox.height($(window).height()-80);
            $(".mainNav").height($(window).height()-255);
            $(window).resize(function(){
                $wrapIndex.height($(window).height());
                $left.height($(window).height()-80);
                $iframeBox.height($(window).height()-80);
                $iframeBox.width($(window).width()-$left.width());
                $(".mainNav").height($(window).height()-255);
            });
        }
    };
    index.init();
});